/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package Donnees;

import java.io.Serializable;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import javax.xml.bind.annotation.XmlRootElement;

/**
 *
 * @author mizho
 */
@Entity
@Table(name = "permissionrole")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "PermissionRole.findAll", query = "SELECT p FROM PermissionRole p"),
    @NamedQuery(name = "PermissionRole.findByIdpermrole", query = "SELECT p FROM PermissionRole p WHERE p.idpermrole = :idpermrole"),
    @NamedQuery(name = "PermissionRole.findByObjet", query = "SELECT p FROM PermissionRole p WHERE p.objet = :objet")})
public class PermissionRole implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 2147483647)
    @Column(name = "idpermrole")
    private String idpermrole;
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 2147483647)
    @Column(name = "objet")
    private String objet;
    @JoinColumn(name = "role", referencedColumnName = "idrole")
    @ManyToOne(optional = false)
    private Role role;
    @JoinColumn(name = "droit", referencedColumnName = "iddroit")
    @ManyToOne(optional = false)
    private Droit droit;

    public PermissionRole() {
    }

    public PermissionRole(String idpermrole) {
        this.idpermrole = idpermrole;
    }

    public PermissionRole(String idpermrole, String objet) {
        this.idpermrole = idpermrole;
        this.objet = objet;
    }

    public String getIdpermrole() {
        return idpermrole;
    }

    public void setIdpermrole(String idpermrole) {
        this.idpermrole = idpermrole;
    }

    public String getObjet() {
        return objet;
    }

    public void setObjet(String objet) {
        this.objet = objet;
    }

    public Role getRole() {
        return role;
    }

    public void setRole(Role role) {
        this.role = role;
    }

    public Droit getDroit() {
        return droit;
    }

    public void setDroit(Droit droit) {
        this.droit = droit;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (idpermrole != null ? idpermrole.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof PermissionRole)) {
            return false;
        }
        PermissionRole other = (PermissionRole) object;
        if ((this.idpermrole == null && other.idpermrole != null) || (this.idpermrole != null && !this.idpermrole.equals(other.idpermrole))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "Donnees.PermissionRole[ idpermrole=" + idpermrole + " ]";
    }
    
}
